import express from 'express';
import sql from '../../sql.js';
const router = express.Router();
router.get('/', async (req, res) => {
  const id = req.query.id;
  if (id) {
      const [data] = await sql.query('SELECT * FROM user WHERE ID =?', [id]);
      if (data.length > 0) {
          res.send(data[0]);
      } else {
          res.status(404).send('用户不存在');
      }
  } else {
      const [data] = await sql.query('SELECT * FROM user');
      res.send(data);
  }
});

export default router;

